import { Body, Controller, Get, Post, Query, Req } from '@nestjs/common';
import { FrontService } from '../../service/front.service';
import { FrontAuthService } from '../../service/front-auth.service';
import { WordService } from '../../service/word.service';
import LoginFrontDto from '../../Dto';
@Controller('front')
export class FrontController {
    constructor(
        private frontService: FrontService,
        private frontAuthService: FrontAuthService,
        private wordService: WordService
    ) { }

    @Post('/login')
    login(@Body('info') info: LoginFrontDto, @Req() req) {
        console.log();
        return this.frontService.login(info)
    }

    @Get('/verify')
    verify(@Query('token') token: string) {
        return this.frontAuthService.verifyToken(token)
    }

    @Get('/test')
    test() {
        return this.frontAuthService.verifyToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImxpeWF0YWkiLCJwYXNzd29yZCI6ImxpeWF0YWkwMTE5IiwiaWF0IjoxNzQyNTM4MTU5LCJleHAiOjE3NDUxMzAxNTl9.zcOhGA9JpFzL0gbFzJWTEr5RVqE4DmJP3oHP6i_o9zA')
    }

    @Get('/getWord')
    getWord(@Query("name") name: string) {
        console.log("name:", name);
        return this.wordService.GetWords(name)
    }

    @Get('/getOptions')
    getOptions() {
        return this.wordService.GetOptions()
    }
}
